<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="checkbox" v-model='isshow'>
        <!--
            js钩子：
            v-on:before-enter
            v-on:enter
            v-on:leave
            v-bind:css="false" // 跳过css的检测
        -->
        <transition @enter='myEnter' @leave='myLeave'>
            <button v-show='isshow'>可以隐藏的按钮</button>
        </transition>
    </div>
    <script src='vue.js'></script>
    <script>
        new Vue({
            el:'#app',
            data:{
                isshow:true,
            },
            methods:{
                myEnter:function(el,done){
                    console.log('进入动画要开始了')
                    var opa = 0
                    var timer = setInterval(function(){
                        opa += 0.1
                        el.style.opacity = opa
                        if(opa>=1){
                            clearInterval(timer)
                            done()
                        }
                    },100)
                },
                myLeave:function(el,done){
                    console.log('离开动画要开始了')
                    var opa = 1
                    var timer = setInterval(function(){
                        opa -= 0.1
                        el.style.opacity = opa
                        if(opa<0){
                            clearInterval(timer)
                            done()
                        }
                    },100)
                }
            }
        })
    </script>
</body>
</html>